from polls.models import Poll
from polls.models import Choice
from django.contrib import admin

class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 3

class PollAdmin(admin.ModelAdmin):
    list_display = ("question", "created_at", "was_published_today")
    search_fields = ["question"]
    date_hierarchy = "created_at"
    list_filter = ["created_at"]
    fieldsets = [
                    (None,                      {"fields": ["question"]})
                    , ("Date information",      {"fields": ["created_at"], "classes": ["collapse"]})
                 ]
    inlines = [ChoiceInline]

admin.site.register(Poll, PollAdmin)
